#include "NewGame.h"

NewGame::NewGame(Screen* s)
{
        screen=s;
}

NewGame::~NewGame(){
//Destructeur
}


int NewGame::main(){
            Image background;
            background.LoadFromFile("Images/Interface/background.png");
            Sprite back;
            back.SetImage(background);

            screen->setNewGameSprite(&back);
            sf::Font myFont;
            if (!myFont.LoadFromFile("font.ttf", 24))
            {
                cout << "Echec loading font"<<endl;
            }
            int positionLigne = 1;  // Pour positionner le bouton qui sert a cliquer.7
            int positionColone = 1; // Pour positioner le bouton a la colone correspondante.

while (screen->getRenderWindow().IsOpened())
    {
    while (screen->getRenderWindow().GetEvent(event)){


            if((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::Right) && (positionColone < 7))
            {
                positionColone++;
            }
            else if((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::Left) && (positionColone > 1))
            {
                positionColone--;
            }
            else if((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::Up) && (positionLigne > 1))
            {
                positionLigne--;
            }
            else if((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::Down) && (positionLigne < 4))
            {
                positionLigne++;
            }
            else if((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::Escape))
                {
                    screen->getRenderWindow().Close(); // fermeture de l'application
                }
            else if((event.Type == sf::Event::KeyPressed)&&(event.Key.Code==sf::Key::A))
            {
                World world;
                world.setScreen(screen);
                world.main();
                return EXIT_SUCCESS;
            }

            screen->drawNewGameMenu();


            sf::String s("EN CONSTRUCTION, VEUILLEZ APPUYER SUR A POUR ACCEDER AU JEU.",myFont,20); // On recupere le nom de l'attaquant.
            s.SetPosition(0,10);

            screen->getRenderWindow().Draw(s);
            screen->display();
        }
    }
    return EXIT_SUCCESS;
}

